<?php
/**
 * 积分兑换
 * @author Ice <iceinto@mallog.com.cn>
 */
class CreditAction extends BaseAction
{
    public function index()
    {

    }

    /**
     * 获取积分详细
     * @author Ice <iceinto@mallog.com.cn>
     */
    public function item()
    {
        $id = intval($this->_get('id'));
        $LimitedModel = D('Limited');
        $limited = $LimitedModel->field('id,mid,fid,bid,title,content,create_time,start_time,end_time')->find($id);
        if (empty($limited)) {
            $this->dataReturn('积分兑换信息不对', 0, 0);
        }
        $limited['push'] = $LimitedModel->getPush($limited['id']);
        $address = $LimitedModel->getAdMFB($limited['mid'], $limited['fid'], $limited['bid']);
        $limited = array_merge($limited, $address);
        $this->dataReturn($limited, 0, 1);
    }

    /**
     * 获取当前积分兑换列表
     * @author Ice <iceinto@mallog.com.cn>
     */
    public function items()
    {
        $limiteds = array();
        $LimitedModel = D('Limited');
        $limiteds = $LimitedModel->getNows();
        foreach ($limiteds as $key => $limited) {
            if ($limited['end_time'] < time() || $limited['surplus'] <= 0) {
                unset($limiteds[$key]);
            }
        }
        $this->dataReturn($limiteds, 0, 1);
    }

    /**
     * 执行兑换
     * @author Ice <iceinto@mallog.com.cn>
     */
    public function receive()
    {
    }
}

?>